<extend name="Public/base" />

<block name="body">
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>

	<div class="main-title">
		<h2>编辑资讯</h2>
	</div>
	<div class="tab-wrap">
		<form action="__SELF__" method="post" class="form-horizontal">
			<div class="form-item">
				<label class="item-label">标题<span class="check-tips">（不能为空）</span></label>
				<div class="controls">
					<input type="text" class="text input-large" name="title" value="{$newsInfo.title}">
				</div>
			</div>
			<div class="form-item">
				<label class="item-label">热门</label>
				<div class="controls">
					<select name="is_hot">
						<option value="0" <eq name="newsInfo.is_hot" value="0">selected="selected"</eq>>否</option>
						<option value="1" <eq name="newsInfo.is_hot" value="1">selected="selected"</eq>>是</option>
					</select>
				</div>
			</div>
			<div class="form-item">
				<label class="item-label">栏目</label>
				<div class="controls">
					<select name="type">
						<foreach name="title" item="val">
							<option value="{$val.id}" <eq name="newsInfo.id" value="{val.id}">selected="selected"</eq>>{$val.title}</option>
						</foreach>
					</select>
				</div>
			</div>
			<div class="form-item">
				<label class="item-label">内容</label>
				<div class="controls">
					<label class="textarea" style="height:200px;overflow:scroll">
						<textarea name="content" placeholder="内容" value="{$newsInfo.content|strip_tags}">{$newsInfo.content}</textarea>
						{:hook('adminArticleEdit', array('name'=>'content','value'=>$newsInfo['content']))}
					</label>
				</div>
			</div>
			<br>
			<div class="form-item">
				<label class="col-xs-2 control-label">上传视频：</label>
				<div class="controls">
					<input id="file_video" name="file_video" type="file">
					<input type="hidden" name="movie_id" id="movie_id" value="{$newsInfo.movie_id}" />
				</div>
				<div class="col-xs-10 filesmoviw"></div>
			</div>


			<input type="hidden" name="id" value="{$newsInfo.id}">
			<div class="form-item">
				<button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">保存</button>
				<button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
			</div>
		</form>
	</div>
</block>
<block name="script">
	<link rel="stylesheet" type="text/css" href="__STATIC__/bootstrap/css/bootstrap-select.css" />
	<link rel="stylesheet" type="text/css" href="__STATIC__/bootstrap/css/bootstrap-typeahead.css" />
	<link rel="stylesheet" href="__STATIC__/uploadify/uploadify.css">
	<script type="text/javascript" src="__STATIC__/bootstrap/js/bootstrap.js"></script>
	<script type="text/javascript" src="__STATIC__/bootstrap/js/bootstrap-select.js"></script>
	<script type="text/javascript" src="__STATIC__/bootstrap/js/bootstrap-typeahead.js"></script>
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	<script type="text/javascript">

		/* 初始化上传插件 */
        $("#file_video").uploadify({
            "height"          : 30,
            "swf"             : "__STATIC__/uploadify/uploadify.swf",
            "fileObjName"     : "download",
            "buttonText"      : "上传视频文件",
            "uploader"        : "{:U('File/uploadMovie',array('session_id'=>session_id()))}",
            "width"           : 120,
            'removeTimeout'	  : 1,
            'multi'			  : false,
            'fileTypeExts'	  : '*.flv; *.avi; *.wma; *.rmvb; *.rm; *.flash; *.mp4; *.mid; *.3gp; *.qlv;',
            "onUploadSuccess" : uploadMovie,
            'onFallback' : function() {
                alert('未检测到兼容版本的Flash.');
            }
        });

        function uploadMovie(file, data){
            var data = $.parseJSON(data);
            if(data.status){
                $(".filesmoviw").append(
                    "<p class='file-info'>文件名称：<span class='file-name'>"
                    +file.name
                    +"</span>"
                    +"<input type='hidden' name='movie_id' value="+data.info.id+" />"
                    +"<a class='fr' href='javascript:;'><i class='icon-remove icon-large'></i></a></p>"
                );

            } else {
                alert(data.info);
                setTimeout(function(){
                    $('#top-alert').find('button').click();
                    $(that).removeClass('disabled').prop('disabled',false);
                },1500);
            }
        }

        $("div").delegate(".icon-remove","click",function(){
            $(this).closest('p').remove();
        });

	</script>
</block>